﻿<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>设置我的资料</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/plugins/layuiadmin/style/admin.css" media="all">
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">设置我的资料</div>
          <div class="layui-card-body" pad15>
            <div class="layui-form" lay-filter="userprofile-form">
              <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-inline">
                  <input type="text" name="username" value="" readonly class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">不可修改。一般用于后台登入名</div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                  <input type="text" name="realname" value="" lay-verify="realname" autocomplete="off" placeholder="请输入姓名" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                  <input type="radio" name="gender" value="男" title="男">
                  <input type="radio" name="gender" value="女" title="女" checked>
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">头像</label>
                <div class="layui-input-inline">
                  <input name="avatar" id="LAY_avatarSrc" placeholder="图片地址" value="" class="layui-input">
                </div>
                <div class="layui-input-inline layui-btn-container" style="width: auto;">
                  <button type="button" class="layui-btn layui-btn-primary" id="LAY_avatarUpload">
                    <i class="layui-icon">&#xe67c;</i>上传图片
                  </button>
                  <button class="layui-btn layui-btn-primary" layadmin-event="avartatPreview">查看图片</button >
                </div>
             </div>
              <div class="layui-form-item">
                <label class="layui-form-label">身份证号</label>
                <div class="layui-input-inline">
                  <input type="text" name="pid" value="" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">手机</label>
                <div class="layui-input-inline">
                  <input type="text" name="phone" value="" lay-verify="phone" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                  <input type="text" name="email" value="" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                  <textarea name="content" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
              </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit lay-filter="setmyinfo">确认修改</button>
                </div>
              </div>
            </div>
            
          </div>
        </div>
      </div>
    </div>
  </div>

  <script src="/plugins/layui/layui.js"></script>
  <script>
      layui.config({
          base: '/plugins/layuiadmin/' //静态资源所在路径
      }).extend({
          index: 'lib/index' //主入口模块
      }).use(['index', 'set', 'form'], function () {
          var $ = layui.$, form = layui.form;
          var load_start = layer.load(2);
          $.ajax({
              type: "get",
              url: "userprofile",
              dataType: "json",
              success: function (res) {
                  layer.close(load_start);
                  if (res.code == 0) {
                      form.val("userprofile-form", res.data);
                  }
                  else {
                      layer.alert(data.msg);
                  }
              }
          });

          //设置我的资料
          form.on('submit(setmyinfo)', function (obj) {
              var load_index = layer.load(2);
              $.ajax({
                  type: "post",
                  url: "userprofile",
                  data: obj.field,
                  dataType: "json",
                  success: function (res) {
                      if (res.code == 0) {
                          layer.close(load_index);
                          layer.msg(res.msg, { time: 1 * 1000 });
                      }
                      else {
                          layer.close(load_index);
                          layer.alert(res.msg)
                      }
                  }
              });
              return false;
          });
      });
  </script>
</body>
</html>